package com.example.checkqufuface.Customer;

import android.content.Context;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.example.checkqufuface.Adapter.SexKaAdapter;
import com.example.checkqufuface.R;

import java.util.ArrayList;
import java.util.List;

public class BottomDialog extends BottomDialogBase implements View.OnClickListener {

    private Context context;
    private EditText name;
    private TextView sex;
    private RecyclerView rlSex;
    private EditText id;
    private EditText phoneNumber;
    private final SexKaAdapter sexAdapter;
    private List<String> sexList;
    private TextView queren;
    private ComfirmListener comfirmListener;
    private ImageView close;


    public BottomDialog(Context context,String cName,String cSex,String cId) {
        super(context);
        this.context = context;
        if (sexList == null) {
            sexList = new ArrayList<>();
        }
        sexList.add("男");
        sexList.add("女");
        sexAdapter = new SexKaAdapter(context, sexList);
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(context);
        rlSex.setLayoutManager(linearLayoutManager);
        rlSex.setAdapter(sexAdapter);

        sexAdapter.SetSexClickListener(new SexKaAdapter.SexClickListener() {
            @Override
            public void sexSelect(int pos) {
                sex.setText(sexList.get(pos));
            }
        });

        name.setText(cName);
        sex.setText(cSex);
        id.setText(cId);

        queren.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                comfirmListener.comfirm(name.getText().toString(),sex.getText().toString(),id.getText().toString(),phoneNumber.getText().toString());
            }
        });

        close.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });
    }

    @Override
    protected void onCreate() {
        setContentView(R.layout.widget_make_ka);


        name = findViewById(R.id.tv_widget_name);
        sex = findViewById(R.id.tv_widget_xinbie);
        rlSex = findViewById(R.id.rl_tv_sex_selete);
        id = findViewById(R.id.tv_widget_leixin);
        phoneNumber = findViewById(R.id.tv_widget_haoma);
        queren = findViewById(R.id.popup_queren_infor);

        close = findViewById(R.id.iv_wg_qu_xiao_ka);


    }

    @Override
    public void onClick(View v) {
        dismiss();
    }

    public interface ComfirmListener{
        void  comfirm(String name,String sex,String id,String phone);
    }

    public void setComfirmListener(ComfirmListener comfirmListener){
        this.comfirmListener = comfirmListener;
    }

}


